

import React, { Component } from 'react'
import { connect } from 'react-redux'
import * as actions from '../store/action'
import { bindActionCreators } from 'redux'

export class Yueb extends Component {
  render() {
    console.log(this);
    const {num,flag,dianjishijian}=this.props
    console.log(num);
    return (
      <div>
        <h2>{num}</h2>
        <button onClick={()=>{this.props.zengjiashijian()}}>++++++++++</button>
        {flag?'开':'关'}
        <button onClick={()=>{dianjishijian()}}>开关</button>
      </div>
    )
  }
}

const mapStateToProps = (state) => ({...state.reducer})

const mapDispatchToProps = (dispatch)=>{
  return bindActionCreators(actions,dispatch)
}

export default connect(mapStateToProps, mapDispatchToProps)(Yueb)

